﻿using System;
using System.Collections.Generic; 
using System.Text;

namespace Runda.EShop.Common.Utility
{
    [Serializable]
    public class UserTokenData
    {
        public UserTokenData() { }

        public UserTokenData(Guid userID, string userName,string userCode,Guid entID,string entCode,string entName,string co,int enttype)
        {
            this.userID = userID;
            this.userName = userName;
            this.userCode = userCode;
            this.entID = entID;
            this.entCode = entCode;
            this._CO = co;
            this.entName = entName;
            this._entType = enttype;
        }

        private Guid userID;

        public Guid UserID
        { get { return userID; } }

        private string userName; 
        public string UserName
        {
            get { return userName; }
        }

        private string userCode;
        public string UserCode
        {
            get { return userCode; }
        }

        private Guid entID;

        public Guid EntID
        { get { return entID; } }

        private string entCode=string.Empty;
        public string EntCode
        {
            get { return entCode; }
        }

        private string entName=string.Empty;
        public string EntName
        {
            get { return entName; }
        }

        private string _CO=string.Empty;
        public string CO
        { get { return _CO; } }

        private int _entType = 0;
        public int EntType
        {
            get { return _entType; } 
        }

        public void BuildUserData(string userData)
        {
            if (!string.IsNullOrEmpty(userData))
            {
                string[] fields = userData.Split(',');
                this.userID = new Guid(fields[0]);
                this.userName = fields[1];
                this.userCode = fields[2];
                this.entID = new Guid(fields[3]);
                this.entCode = fields[4];
                this.entName = fields[5];
                this._CO = fields[6];
                this._entType = Convert.ToInt32(fields[7]);
            }
        }

        public string GetUserData()
        {
            return string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", userID, userName,userCode,entID,entCode,entName,_CO,_entType);
        }

        public override string ToString()
        {
            return GetUserData();
        }
    }
}
